import axios from 'axios'

// 新建axios实例
const instance = axios.create({
  headers: { 'Content-Type': 'application/json;charset=UTF-8' },
  baseURL: '/Design',
  timeout: 18000
})

// 添加请求拦截器
instance.interceptors.request.use(config => {
  // 设置请求头，解决获取不到参数
  const token = sessionStorage.getItem('token')
  if (token) {
    config.headers.token = token
  }
  return config
}, error => {
  return Promise.reject(error)
})

// 添加相应拦截器
instance.interceptors.response.use(res => {
  return res.data
}, error => {
  return Promise.reject(error)
})

export default instance
